<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <div id="name">FX</div>
</div>
<script>
    let data = {
        name:'',
    }
    let name = ''
    Object.defineProperty(data,'name',{
        get(){
            console.log('调用get > '+name)
            return name
        },
        set(val){
            console.log('current: '+val+'    old: '+name)
            if (val !== name){
                document.getElementById('name').innerHTML = val
            }
            name = val
            console.log('调用set > '+name)
        }
    })
    data.name = '符幸'
    data.name = '符幸2'
    console.log(data.name)
</script>
</body>
</html>